#include <iostream>
#include <vector>

using namespace std;

class Solution
{
public:
    int maxAbsoluteSum(vector<int> &nums)
    {
        vector<int> dpMax(nums.size() + 1);
        vector<int> dpMin(nums.size() + 1);
        int maxV = 0;
        for (int i = 0; i < nums.size(); i++)
        {
            dpMax[i + 1] = max(dpMax[i], 0) + nums[i];
            dpMin[i + 1] = min(dpMin[i], 0) + nums[i];
            maxV = max(maxV, max(abs(dpMax[i + 1]), abs(dpMin[i + 1])));
        }
        return maxV;
    }
};
int main()
{
    cout << "Code1749" << endl;
    Solution s;
    vector<int> nums = {2, -5, 1, -4, 3, -2};
    cout << s.maxAbsoluteSum(nums) << endl;
    return 0;
}